const appInstance = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    inputShowed: false,
    inputVal: "",
    list: [],
    navHeight: 0,
    effectiveHeight: 0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    let list = []
    for (let i = 1; i <= 20; i++) {
      list.push({
        img: `https://dummyimage.com/100x100/4A7BF7&text=${i}`,
        name: `张学友${i}`,
        tel: `${13770000000 + i}`,
        school: '苏州实验小学',
        role: `${ i % 3 == 0 ? '教师' : '学生'}`
      })
    }
    this.setData({
      list: list,
      navHeight: appInstance.globalData.navHeight,
      effectiveHeight: appInstance.globalData.effectiveHeight,
    })
  },

  showInput: function() {
    this.setData({
      inputShowed: true
    });
  },
  hideInput: function() {
    this.setData({
      inputVal: "",
      inputShowed: false
    });
  },
  clearInput: function() {
    this.setData({
      inputVal: ""
    });
  },
  inputTyping: function(e) {
    this.setData({
      inputVal: e.detail.value
    });
  },

  showDetail() {
    wx.navigateTo({
      url: '/pages/detail/detail'
    })
  },

  /**
   * 拨打电话
   */
  callPhone(ev) {
    wx.makePhoneCall({
      phoneNumber: ev.target.dataset.phone
    })
  }
})